//
//  UIView+wdp_layout.h
//  WDPubFramework
//
//  Created by gadmyth on 3/20/17.
//  Copyright © 2017 wanda. All rights reserved.
//

#import <UIKit/UIKit.h>

// 获取 View bounds 的各种属性
#define V2B(V)     (V.bounds.origin.y + V.bounds.size.height)
#define V2L(V)      V.bounds.origin.x
#define V2R(V)     (V.bounds.origin.x + V.bounds.size.width)
#define V2T(V)      V.bounds.origin.y

// 获取 View 一级属性
#define VF(V) V.frame
#define VS(V) v.frame.size
#define VO(V) v.frame.origin

// 获取 CGRect 的属性, 用于左侧赋值使用, view 的 frame/bounds 的属性为 readonly
#define FW(F) F.size.width
#define FH(F) F.size.height
#define FL(F) F.origin.x
#define FR(F) FR(F) + FW(F)
#define FT(F) F.origin.y
#define FB(F) FT(F) + FH(F)

//设置View的width, height, left, top值方法的macro声明
#define Vdefine(type) \
void V##type##set(UIView *V, CGFloat value);

Vdefine(W)
Vdefine(H)
Vdefine(L)
Vdefine(T)

// 获取view的frame四个角的Point方法的macro声明
#define Pdefine(y, x) \
CGPoint V##y##x(UIView *V);

Pdefine(T, L);
Pdefine(T, R);
Pdefine(B, L);
Pdefine(B, R);

// 获取view的bounds四个角的Point方法的macro声明
#define P2define(y, x) \
CGPoint V2##y##x(UIView *V);

P2define(T, L);
P2define(T, R);
P2define(B, L);
P2define(B, R);

typedef NS_ENUM(NSUInteger, WDAlign) {
    WDAlignLeft,
    WDAlignRight,
    WDAlignTop,
    WDAlignBottom,
    WDAlignCenterVertical,
    WDAlignCenterHorizontal,
    WDFixedAlignLeft,
    WDFixedAlignRight,
    WDFixedAlignTop,
    WDFixedAlignBottom
};

@interface UIView (wdp_layout)

- (void)alignTo:(UIView *)view type:(WDAlign)align margin:(CGFloat)margin;
- (void)alignToParent:(WDAlign)align margin:(CGFloat)margin;
- (void)leftTo:(UIView *)view margin:(CGFloat)margin;
- (void)fixedLeftTo:(UIView *)view margin:(CGFloat)margin;
- (void)rightTo:(UIView *)view margin:(CGFloat)margin;
- (void)fixedRightTo:(UIView *)view margin:(CGFloat)margin;
- (void)bottomTo:(UIView *)view margin:(CGFloat)margin;
- (void)fixedBottomTo:(UIView *)view margin:(CGFloat)margin;
- (void)topTo:(UIView *)view margin:(CGFloat)margin;
- (void)fixedTopTo:(UIView *)view margin:(CGFloat)margin;

@end
